package com.plter.controls.plter
{
	import flash.display.DisplayObject;

	public class PViewStack extends PUIComponent
	{
		private var viewsArr:Array;
		
		public function PViewStack()
		{
			viewsArr=[];
			this.useMask=true;
			this.width=200;
			this.height=400;
		}
		
		public function push(view:DisplayObject):void{
			viewsArr.push(view);
		}
		
		public function pop():DisplayObject{
			return viewsArr.pop();
		}
		
		public function selectIndex(index:int):void{
			var len:int=length;
			for(var i:int=0;i<len;i++){
				viewsArr[i].visible=i==index;
			}
		}
		
		public function selectView(view:DisplayObject):void{
			var len:int=length;
			for each(var obj:DisplayObject in viewsArr){
				obj.visible=obj==view;
			}
		}
		
		public function get length():int{
			return viewsArr.length;
		}
	}
}